]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Adjust folder position
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 24 Sep 2020 15:00:03 +0000 (12:00 -0300)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 5 Oct 2020 12:06:47 +0000 (12:06 +0000)
If you try and drop an icon that's in the same page, but before the
drop target, it'll be one position ahead of where it should be -
because we just removed one icon before the target position.

Adjust the final position of the to-be-created folder.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1447

js/ui/appDisplay.js

index 6011d72ee661451abe2753ba5b5b41262a6a9c90..b704a5460121bd95c4d49e267c650a6d63dd2e59 100644 (file)
@@ -1314,9 +1314,18 @@ class AppDisplay extends BaseAppView {
 
         // The hovered AppIcon always passes its own id as the first
         // one, and this is where we want the folder to be created
-        const [folderPage, folderPosition] =
+        let [folderPage, folderPosition] =
             this._grid.getItemPosition(this._items.get(apps[0]));
 
+        // Adjust the final position
+        folderPosition -= apps.reduce((counter, appId) => {
+            const [page, position] =
+                this._grid.getItemPosition(this._items.get(appId));
+            if (page === folderPage && position < folderPosition)
+                counter++;
+            return counter;
+        }, 0);
+
         let appItems = apps.map(id => this._items.get(id).app);
         let folderName = _findBestFolderName(appItems);
         if (!folderName)